/*
=======================================================================

  BOTS Bodyguard Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_BODYGUARD_LASER		110
#define BOTS_BODYGUARD_LASERON		111
#define BOTS_BODYGUARD_LASEROFF		112
#define BOTS_BODYGUARD_LASERKILL	113
#define BOTS_BODYGUARD_DECOY		114
#define BOTS_BODYGUARD_PROTECT		115
#define BOTS_BODYGUARD_PULSE		116
#define BOTS_BODYGUARD_LASERTOG		117

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	laser;
  menutext_s	laseron;
  menutext_s	laseroff;
  menutext_s	lasertog;
  menutext_s	laserkill;
  menutext_s	decoy;
  menutext_s	protect;
  menutext_s	pulse;
  menutext_s	cancel;
} bodyguardCommands_t;

static bodyguardCommands_t		s_bodyguard;

/*
=================
BOTS_BodyguardCommandsMenu_Event
callback routine
=================
*/
void BOTS_BodyguardCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_BODYGUARD_LASER:
		trap_Cmd_ExecuteText( EXEC_APPEND, "laser\n" );
		break;
	case BOTS_BODYGUARD_LASERON:
		trap_Cmd_ExecuteText( EXEC_APPEND, "laseron\n" );
		break;
	case BOTS_BODYGUARD_LASEROFF:
		trap_Cmd_ExecuteText( EXEC_APPEND, "laseroff\n" );
		break;
	case BOTS_BODYGUARD_LASERTOG:
		trap_Cmd_ExecuteText( EXEC_APPEND, "lasertog\n" );
		break;
	case BOTS_BODYGUARD_LASERKILL:
		trap_Cmd_ExecuteText( EXEC_APPEND, "laserkill\n" );
		break;
	case BOTS_BODYGUARD_DECOY:
		trap_Cmd_ExecuteText( EXEC_APPEND, "decoy\n" );
		break;
	case BOTS_BODYGUARD_PROTECT:
		trap_Cmd_ExecuteText( EXEC_APPEND, "protect\n" );
		break;
	case BOTS_BODYGUARD_PULSE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "pulse\n" );
		break;
		
	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_BodyguardCommandsMenu_Init
=================
*/
void BOTS_BodyguardCommandsMenu_Init() 
{
	int y;

	memset( &s_bodyguard, 0 ,sizeof(bodyguardCommands_t) );
	s_bodyguard.menu.wrapAround = qtrue;
	s_bodyguard.menu.fullscreen = qfalse;

	y = 96;
	s_bodyguard.title.generic.type	= MTYPE_PTEXT;
	s_bodyguard.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_bodyguard.title.generic.x		= 320;
	s_bodyguard.title.generic.y		= y;
	s_bodyguard.title.string		= "BODYGUARD COMMANDS MENU";
	s_bodyguard.title.color			= color_bots_menu;
	s_bodyguard.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.laser.generic.type		= MTYPE_PTEXT;
	s_bodyguard.laser.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.laser.generic.x			= 320;
	s_bodyguard.laser.generic.y			= y;
	s_bodyguard.laser.generic.id		= BOTS_BODYGUARD_LASER;
	s_bodyguard.laser.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.laser.string			= "CREATE A LASER - laser";
	s_bodyguard.laser.color				= color_bots_menu;
	s_bodyguard.laser.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.laseron.generic.type		= MTYPE_PTEXT;
	s_bodyguard.laseron.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.laseron.generic.x			= 320;
	s_bodyguard.laseron.generic.y			= y;
	s_bodyguard.laseron.generic.id			= BOTS_BODYGUARD_LASERON;
	s_bodyguard.laseron.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.laseron.string				= "TURN LASER ON - laseron";
	s_bodyguard.laseron.color				= color_bots_menu;
	s_bodyguard.laseron.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.laseroff.generic.type		= MTYPE_PTEXT;
	s_bodyguard.laseroff.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.laseroff.generic.x			= 320;
	s_bodyguard.laseroff.generic.y			= y;
	s_bodyguard.laseroff.generic.id			= BOTS_BODYGUARD_LASEROFF;
	s_bodyguard.laseroff.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.laseroff.string				= "TURN LASER OFF - laseroff";
	s_bodyguard.laseroff.color				= color_bots_menu;
	s_bodyguard.laseroff.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.lasertog.generic.type		= MTYPE_PTEXT;
	s_bodyguard.lasertog.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.lasertog.generic.x			= 320;
	s_bodyguard.lasertog.generic.y			= y;
	s_bodyguard.lasertog.generic.id			= BOTS_BODYGUARD_LASERTOG;
	s_bodyguard.lasertog.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.lasertog.string				= "TOGGLE LASERS - lasertog";
	s_bodyguard.lasertog.color				= color_bots_menu;
	s_bodyguard.lasertog.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.laserkill.generic.type		= MTYPE_PTEXT;
	s_bodyguard.laserkill.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.laserkill.generic.x			= 320;
	s_bodyguard.laserkill.generic.y			= y;
	s_bodyguard.laserkill.generic.id		= BOTS_BODYGUARD_LASERKILL;
	s_bodyguard.laserkill.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.laserkill.string			= "DESTROY LASER - laserkill";
	s_bodyguard.laserkill.color				= color_bots_menu;
	s_bodyguard.laserkill.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.decoy.generic.type		= MTYPE_PTEXT;
	s_bodyguard.decoy.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.decoy.generic.x			= 320;
	s_bodyguard.decoy.generic.y			= y;
	s_bodyguard.decoy.generic.id		= BOTS_BODYGUARD_DECOY;
	s_bodyguard.decoy.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.decoy.string			= "DECOY FLAG - DECOY";
	s_bodyguard.decoy.color				= color_bots_menu;
	s_bodyguard.decoy.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 1) {
		s_bodyguard.pulse.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.protect.generic.type		= MTYPE_PTEXT;
	s_bodyguard.protect.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.protect.generic.x			= 320;
	s_bodyguard.protect.generic.y			= y;
	s_bodyguard.protect.generic.id			= BOTS_BODYGUARD_PROTECT;
	s_bodyguard.protect.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.protect.string				= "TOGGLE PROTECT - protect";
	s_bodyguard.protect.color				= color_bots_menu;
	s_bodyguard.protect.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.pulse.generic.type		= MTYPE_PTEXT;
	s_bodyguard.pulse.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.pulse.generic.x			= 320;
	s_bodyguard.pulse.generic.y			= y;
	s_bodyguard.pulse.generic.id		= BOTS_BODYGUARD_PULSE;
	s_bodyguard.pulse.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.pulse.string			= "LASER PULSE MODE - pulse";
	s_bodyguard.pulse.color				= color_bots_menu;
	s_bodyguard.pulse.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 4) {
		s_bodyguard.pulse.generic.flags |= QMF_GRAYED;
	}

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_bodyguard.cancel.generic.type		= MTYPE_PTEXT;
	s_bodyguard.cancel.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_bodyguard.cancel.generic.x		= 320;
	s_bodyguard.cancel.generic.y		= y;
	s_bodyguard.cancel.generic.id		= BOTS_CANCEL;
	s_bodyguard.cancel.generic.callback	= BOTS_BodyguardCommandsMenu_Event; 
	s_bodyguard.cancel.string			= "CANCEL";
	s_bodyguard.cancel.color			= color_bots_menu;
	s_bodyguard.cancel.style			= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.title );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.laser );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.laseron );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.laseroff );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.lasertog );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.laserkill );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.decoy );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.protect );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.pulse );
	Menu_AddItem( &s_bodyguard.menu, &s_bodyguard.cancel );
}

void BOTS_BodyguardCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_BodyguardCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_bodyguard.menu );
}
